package com.sec.samsung.android.app.baymax.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;
import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sec.samsung.android.app.baymax.model.user.UserList;

public class BaymaxUtils {

    public static UserList getUserList(Context context) {
        String userListStr = SharePrefUtils.getStringValue(context, BaymaxConstant.KEY_USER_LIST_DATA);
        Log.d("KieuThang", "snsListStr:" + userListStr);
        if (StringUtility.isEmpty(userListStr)) {
            return null;
        }
        Gson gson = new GsonBuilder().serializeNulls().create();
        UserList snsList = gson.fromJson(userListStr, UserList.class);
        if (snsList == null)
            return null;
        return snsList;
    }

    public static Bitmap convertBitmapFromString(String encodedImage) {
        if (encodedImage == null)
            return null;
        byte imageByte[] = Base64.decode(encodedImage, Base64.DEFAULT);
        Bitmap bitmap = BitmapFactory.decodeByteArray(imageByte, 0, imageByte.length);
        return bitmap;
    }

}
